//
//  ViewController.m
//  Chrismas2013
//
//  Created by linxiangyu on 12/25/13.
//  Copyright (c) 2013 linxiangyu. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property NSMutableArray *flag;
@end

@implementation ViewController

int a[30];
int count = 0;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    for(int i = 0; i < 30; i++){
        a[i] = 1;

    }

    
}

- (void)initarray{
    for(int i = 0; i < 30; i++){
        a[i] = 1;
    }
    count = 0;
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)changeButtonClick:(UIButton *)sender {
    if (count == 30){
        self.showText.text = @"结束啦";
        return ;
    }
    int randNum = rand() % 30;
    NSLog(@"clcik %d", randNum);
  
    while(a[randNum] == 0){
        randNum = rand() % 30;
    }
    a[randNum] = 0;
    self.showText.text = [NSString stringWithFormat:@"%d", randNum];
    count += 1;
}

- (IBAction)resetButtonClick:(UIButton *)sender {
    
    [self initarray];
    self.showText.text = @"已重置";

}
@end
